package com.wj.algorithm.lintcode;

public class P101 {
    
    public int removeDuplicates(int[] nums) {
        if (nums == null || nums.length < 1) {
            return 0;
        }
        int current = nums[0];
        int count = 1;
        
        int sameCount = 0;
        for(int i = 1, len = nums.length; i < len; i ++) {
            int v = nums[i];
            if(v > current) {
                nums[count] = v;
                count ++;
                current = v;
                sameCount = 0;
            } else if(sameCount < 1) {
                nums[count] = v;
                count ++;
                sameCount ++;
            }
        }
        return count;
    }
    
    public static void main(String[] args) {
        System.out.println(new P101().removeDuplicates(new int[]{-8,0,1,2,3}));
    }
}
